<template>
	<view>
		<view class="likes">
			<view class="fbox fbox-acenter fbox-jbetween">
				<view class="title fbox fbox-acenter">
					<image src="/static/information/line.png" mode="widthFix"></image>
					<text class="color3 f36">Likes</text>
				</view>
				<view class="xin fbox fbox-acenter">
					<image src="/static/news/xin.png" @click="goLike" v-if="isLike == 0" mode="widthFix"></image>
					<image src="/static/information/xin_a.png" @click="goLike" v-if="isLike == 1" mode="widthFix">
					</image>
					<text style="color: #999;" v-if="isLike == 0">{{likeNum}}</text>
					<text style="color: red;" v-if="isLike == 1">{{likeNum}}</text>
				</view>
			</view>
			<view class="likes-cont">
				<image :src="item.avatar" mode="" v-for="item in likeAvatars"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "likes",
		data() {
			return {

			};
		},
		props: {
			likeAvatars: {
				type: Array,
				default () {
					return []
				}
			},
			isLike: {
				type: Number,
				default: 0
			},
			likeNum: {
				type: String,
				default: ""
			},
			id: {
				type: String,
				default: ""
			},
			type: {
				type: String,
				default: ""
			}
		},
		methods: {
			goLike() {
				uni.showLoading({
					mask: true
				})
				const params = {
					map: 'applet_information_like',
				}
				if (this.type == "business") {
					params.map = 'applet_city_shop_like'
					params.aid = this.id
				}
				if (this.type == "information") {
					params.pid = this.id
					params.map = 'applet_city_post_like'
				}
				if (this.type == "news") {
					params.map = 'applet_city_shop_like'
					params.aid = this.id
				}
				console.log(params)
				this.$Request({
					method: 'GET',
					data: params
				}).then(res => {
					if (res.data.ec == 200) {
						uni.hideLoading()
						uni.showToast({
							title: res.data.data.msg,
							icon: "none"
						})
						this.$emit("init")
					} else {
						uni.hideLoading()
					}
				})
			},
		}
	}
</script>

<style lang="less">
	.likes {
		padding: 0rpx 30rpx 0;

		.title {
			padding: 30rpx 0;
			font-weight: bold;

			image {
				width: 8rpx;
				margin-right: 20rpx;
			}
		}

		.xin {
			image {
				width: 40rpx;
				margin-right: 20rpx;
			}

			text {
				color: #ff0000;
			}
		}

		.likes-cont {
			margin-left: 20rpx;

			image {
				width: 50rpx;
				height: 50rpx;
				border-radius: 50%;
				margin-left: -10rpx;
				background-color: #d3d3d3;
			}
		}
	}
</style>
